/*
 *  Copyright (c) 2011, Jordi Vilaplana <gatasuna@gmail.com>
 *  
 *  This file is part of Stats Dashlet.
 *  
 *  Foobar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  
 *  Foobar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 *  
 */


function main() {
    var theUrl, connector, result;
    var viewType = args.viewType;
    // Create XML object to pull values from configuration file
    var conf = new XML(config.script);
    // Use the defaults from the XML configuration file (stats.get.config.xml) if no values in args array
    if (!viewType) { viewType = conf.viewType[0]; }
    // Set values on the model for use in templates
    model.viewType = "" + viewType;
    theUrl = "/jordiv/stats/alfstats";
    connector = remote.connect("alfresco");
    result = connector.get(theUrl);
    if(result.status == 200) {
        model.stats = eval('(' + result.response + ')');
    }
}

main();
